import { defineStore } from 'pinia'
import { getSystemParams } from '@/common/api/api.js'
// 本地存储配置项存储
export const useConfigStore = defineStore('configStoreId', {
	state() {
		return {
			//是否记住密码配置
			rememberPassword:{
				isChecked:false,
				password:''
			},
			//首次安装是否同意协议配置
			firstInstall:{
				isAgree:false,
			},
			//存储收益类型数据
			incomeTypes:[]
		}
	},
	actions: {
		// 更新首次安装配置
		setFirstInstallConfig(isAgree) {
			this.firstInstall.isAgree = isAgree
		},
		// 更新是否记住密码配置
		setRememberPasswordConfig(password) {
			if(password == '') {
				this.rememberPassword = {
					isChecked:false,
					password:''
				}
			}
			else{
				this.rememberPassword = {
					isChecked:true,
					password
				}
			}
		},
		// 更新收益类型数据
		async updateIncomeTypes() {
			const res = await getSystemParams({categoryCode:'IncomeType'})
			this.incomeTypes = res.result
		}
	},
	//开启数据持久化
	persist: true
})